<!-- START SIGMA IMPORTS -->
<script src="../src/sigma.core.js"></script>
<script src="../src/conrad.js"></script>
<script src="../src/utils/sigma.utils.js"></script>
<script src="../src/utils/sigma.polyfills.js"></script>
<script src="../src/sigma.settings.js"></script>
<script src="../src/classes/sigma.classes.dispatcher.js"></script>
<script src="../src/classes/sigma.classes.configurable.js"></script>
<script src="../src/classes/sigma.classes.graph.js"></script>
<script src="../src/classes/sigma.classes.camera.js"></script>
<script src="../src/classes/sigma.classes.quad.js"></script>
<script src="../src/classes/sigma.classes.edgequad.js"></script>
<script src="../src/captors/sigma.captors.mouse.js"></script>
<script src="../src/captors/sigma.captors.touch.js"></script>
<script src="../src/renderers/sigma.renderers.canvas.js"></script>
<script src="../src/renderers/sigma.renderers.webgl.js"></script>
<script src="../src/renderers/sigma.renderers.svg.js"></script>
<script src="../src/renderers/sigma.renderers.def.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.nodes.def.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.nodes.fast.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.edges.def.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.edges.fast.js"></script>
<script src="../src/renderers/webgl/sigma.webgl.edges.arrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.labels.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.hovers.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.nodes.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edges.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edges.curve.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edges.arrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edges.curvedArrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edgehovers.def.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edgehovers.curve.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edgehovers.arrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.edgehovers.curvedArrow.js"></script>
<script src="../src/renderers/canvas/sigma.canvas.extremities.def.js"></script>
<script src="../src/renderers/svg/sigma.svg.utils.js"></script>
<script src="../src/renderers/svg/sigma.svg.nodes.def.js"></script>
<script src="../src/renderers/svg/sigma.svg.edges.def.js"></script>
<script src="../src/renderers/svg/sigma.svg.edges.curve.js"></script>
<script src="../src/renderers/svg/sigma.svg.labels.def.js"></script>
<script src="../src/renderers/svg/sigma.svg.hovers.def.js"></script>
<script src="../src/middlewares/sigma.middlewares.rescale.js"></script>
<script src="../src/middlewares/sigma.middlewares.copy.js"></script>
<script src="../src/misc/sigma.misc.animation.js"></script>
<script src="../src/misc/sigma.misc.bindEvents.js"></script>
<script src="../src/misc/sigma.misc.bindDOMEvents.js"></script>
<script src="../src/misc/sigma.misc.drawHovers.js"></script>
<!-- END SIGMA IMPORTS -->
<script src="../plugins/sigma.plugins.image/sigma.plugins.image.js"></script>
<div id="container">
  <style>
 <style>
    body {
      color: #333;
      font-size: 14px;
      font-family: Lato, sans-serif;
    }
    #graph-container {
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      position: absolute;
    }
    #control-pane {
      top: 10px;
      /*bottom: 10px;*/
      right: 10px;
      z-index: 1;
      position: absolute;
      width: 230px;
      background-color: rgb(249, 247, 237);
      box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    }
    #control-pane > div {
      margin: 10px;
      overflow-x: auto;
    }
    .line {
      clear: both;
      display: block;
      width: 100%;
      margin: 0;
      padding: 12px 0 0 0;
      border-bottom: 1px solid #aac789;
      background: transparent;
    }
    h2, h3, h4 {
      padding: 0;
      font-variant: small-caps;
    }
    .green {
      color: #437356;
    }
    h2.underline {
      color: #437356;
      background: #f4f0e4;
      margin: 0;
      border-radius: 2px;
      padding: 8px 12px;
      font-weight: 700;
    }
    .hidden {
      display: none;
      visibility: hidden;
    }

    input[type=range] {
      width: 160px;
    }


    #image-container {
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      position: absolute;
    }
  </style>
  <div id="graph-container"></div>

  <div id="control-pane">
    <h2 class="underline">Image</h2>
    <div>
      <h3>Width <span id="width-value">0</span></h3>
       <input id="width" type="range" min="0" max="3000" step="100" value="0"> <br>
    </div>
    <div>
      <h3>Color</h3>
      <input type="text" id="color" value="#FFFFFF" /><br>
    </div>
    <span class="line"></span>
    <div>
      <button id="snap-btn">Snap full view</button>
      <button id="snapClip-btn">Snap clipped view</button>
    </div>
    <div id="dump" class="hidden"></div>
  </div>

</div>
<script>
/**
 * This is an example on how to use sigma filters plugin on a real-world graph.
 */


/**
 * DOM utility functions
 */
var _ = {
  $: function (id) {
    return document.getElementById(id);
  }
};

function changeWidthValue() {
    var valof = _.$("width").value;
    _.$('width-value').innerHTML = valof;
}

/**
 * Sigma instance
 */
var i,
    s,
    N = 60,
    E = 180;

s = new sigma({
  container: 'graph-container'
});

// Generate a random graph:
for (i = 0; i < N; i++)
  s.graph.addNode({
    id: 'n' + i,
    label: 'Node ' + i,
    x: Math.random(),
    y: Math.random(),
    color: '#666',
    size: 1 + Math.random()
  });

for (i = 0; i < E; i++)
  s.graph.addEdge({
    id: 'e' + i,
    source: 'n' + (Math.random() * N | 0),
    target: 'n' + (Math.random() * N | 0),
    color: '#ccc',
    size: 1 + Math.random()
  });

s.refresh();

/**
 * Events listener
 */

function generateImage(mouse, clip) {
  var size = parseInt(_.$("width").value);
  var color = _.$("color").value;

  sigma.plugins.image(s, s.renderers[0], {
    download: true,
    size: size,
    margin: 50,
    background: color,
    clip: clip,
    zoomRatio: 1,
    labels: false
  });
}

_.$('width').addEventListener("change", changeWidthValue); // for IE10+
_.$('snap-btn').addEventListener("click", generateImage);
_.$('snapClip-btn').addEventListener("click", function(event) {
  generateImage(event, true)
});

</script>
